<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace addons\video\model;

/**
 * Description of video
 * 视频举报表
 * @author
 */
class VideoReport extends \web\common\model\BaseModel{
    
    protected function _initialize(){
        $this->tableName = 'video_report';
    }

    /**
     * 后台列表
     * @param int $pageIndex
     * @param int $pageSize
     * @param string $filter
     * @param string $fields
     * @param string $order
     * @return mixed
     */
    public function getVideoReportList($pageIndex = -1, $pageSize = -1, $filter = '', $fields = 'a.*,b.video_title,b.video_img,b.video_path,c.phone', $order = 'is_dispose asc,id desc') {

        $sql = 'select '.$fields.' from '.$this->getTableName() .' a left join tp_video b on b.id=a.video_id left join tp_member_account as c on c.id=a.user_id ';
        if (!empty($filter))
            $sql .= ' where ' . $filter;
        return $this->getDataListBySQL($sql, $pageIndex, $pageSize, $order);
    }

    /**
     * 后台列表数量
     * @param string $filter
     * @return int
     */
    public function getVideoReportTotal($filter = '') {
        $sql = 'select count(*) as c from '.$this->getTableName() .' a left join tp_video b on b.id=a.video_id left join tp_member_account as c on c.id=a.user_id';
        if (!empty($filter)){
            $sql = $sql . ' where ' . $filter;
        }
        $result = $this->query($sql);
        if (count($result) > 0)
            return intval($result[0]['c']);
        else
            return 0;
    }

}
